// 字符串转数组
exports.StrToArr = (str) => {
  if (str) {
    return str.split(',')
  } else {
    return []
  }
}

// 选项字符串转数组
exports.OptionStrToArr = (str) => {
  if (str) {
    let arr = str.split(',')
    let result = []
    for(let i=0; i<arr.length; i++) {
      result.push({
        code: String.fromCharCode(65+i),
        option: arr[i]
      })
    }
    return result
  } else {
    return null
  }
}

// 选项数组转字符串
exports.OptionArrToStr = (arr) => {
  let str = ''
  for (let i=0; i<arr.length; i++) {
    str = str + arr[i].option
    if (i!==arr.length-1) {
      str += ','
    }
  }
  return str
}

// 数组转字符串
exports.ArrToStr = (arr) => {
  let str = ''
  if (arr.length != 0) {
    for (let i=0; i<arr.length; i++) {
      str = str + arr[i]
      if (i!==arr.length-1) {
        str += ','
      }
    }
  }
  // console.log(str)
  return str
}